<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>列表动画</title>
    <style>
      .list {
        display: inline-block;
        margin-right: 10px;
      }

      .v-enter-from {
        opacity: 0;
        transform: translateY(30px);
      }

      .v-enter-active {
        transition: 0.6s ease-in;
      }

      .v-enter-to {
        opacity: 1;
        transform: translateY(0);
      }

      .v-move {
        transition: 0.6s ease-in;
      }
    </style>
  </head>
  <body>
    <script src="https://unpkg.com/vue@next"></script>
    <div id="root"></div>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            list: [1, 2, 3],
          };
        },

        methods: {
          handleClick() {
            this.list.unshift(this.list.length + 1);
          },
        },

        template: `
                <transition-group>
                    <span class="list" v-for="item in list" :key="item">{{item}}</span>
                </transition-group>
                    <button @click="handleClick">增加</button>  
                `,
      });

      const vm = app.mount("#root");
    </script>
  </body>
</html>
